diff --git a/objects/configurationClearCache.json.php b/objects/configurationClearCache.json.php index 344bb21e0..76f781c90 100644 --- a/objects/configurationClearCache.json.php +++ b/objects/configurationClearCache.json.php @@ -1,36 +1,20 @@ error = true; $obj->msg = ""; if (!User::isAdmin()) { $obj->msg = __("Permission denied"); die(json_encode($obj)); } $dir = "{$global['systemRootPath']}videos/cache"; rrmdir($dir); $obj->error = false; die(json_encode($obj)); \ No newline at end of file diff --git a/objects/functions.php b/objects/functions.php index 2fc1dbf7e..5236eacc5 100644 --- a/objects/functions.php +++ b/objects/functions.php @@ -1,2318 +1,2316 @@ 0 && $upload_max < $max_size) { $max_size = $upload_max; } } return $max_size; } function parse_size($size) { $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size. $size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size. if ($unit) { // Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by. return round($size * pow(1024, stripos('bkmgtpezy', $unit[0]))); } else { return round($size); } } function humanFileSize($size, $unit = "") { if ((!$unit && $size >= 1 << 30) || $unit == "GB") { return number_format($size / (1 << 30), 2) . "GB"; } if ((!$unit && $size >= 1 << 20) || $unit == "MB") { return number_format($size / (1 << 20), 2) . "MB"; } if ((!$unit && $size >= 1 << 10) || $unit == "KB") { return number_format($size / (1 << 10), 2) . "KB"; } return number_format($size) . " bytes"; } function get_max_file_size() { return humanFileSize(file_upload_max_size()); } function humanTiming($time, $precision = 0) { if (!is_int($time)) { $time = strtotime($time); } $time = time() - $time; // to get the time since that moment return secondsToHumanTiming($time, $precision); } function secondsToHumanTiming($time, $precision = 0) { $time = ($time < 0) ? $time * -1 : $time; $time = ($time < 1) ? 1 : $time; $tokens = array( 31536000 => 'year', 2592000 => 'month', 604800 => 'week', 86400 => 'day', 3600 => 'hour', 60 => 'minute', 1 => 'second', ); /** * For detection propouse only */ __('year'); __('month'); __('week'); __('day'); __('hour'); __('minute'); __('second'); __('years'); __('months'); __('weeks'); __('days'); __('hours'); __('minutes'); __('seconds'); foreach ($tokens as $unit => $text) { if ($time < $unit) { continue; } $numberOfUnits = floor($time / $unit); if ($numberOfUnits > 1) { $text = __($text . "s"); } else { $text = __($text); } if ($precision) { $rest = $time % $unit; if ($rest) { $text .= ' ' . secondsToHumanTiming($rest, $precision - 1); } } return $numberOfUnits . ' ' . $text; } } function checkVideosDir() { $dir = "../videos"; if (file_exists($dir)) { if (is_writable($dir)) { return true; } else { return false; } } else { return mkdir($dir); } } function isApache() { if (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) { return true; } else { return false; } } function isPHP($version = "'7.0.0'") { if (version_compare(PHP_VERSION, $version) >= 0) { return true; } else { return false; } } function modEnabled($mod_name) { if (!function_exists('apache_get_modules')) { ob_start(); phpinfo(INFO_MODULES); $contents = ob_get_contents(); ob_end_clean(); return (strpos($contents, 'mod_' . $mod_name) !== false); } else { return in_array('mod_' . $mod_name, apache_get_modules()); } } function modRewriteEnabled() { return modEnabled("rewrite"); } function modAliasEnabled() { return modEnabled("alias"); } function isFFMPEG() { return trim(shell_exec('which ffmpeg')); } function isUnzip() { return trim(shell_exec('which unzip')); } function isExifToo() { return trim(shell_exec('which exiftool')); } function getPathToApplication() { return str_replace("install/index.php", "", $_SERVER["SCRIPT_FILENAME"]); } function getURLToApplication() { $url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $url = explode("install/index.php", $url); $url = $url[0]; return $url; } //max_execution_time = 7200 function check_max_execution_time() { $max_size = ini_get('max_execution_time'); $recomended_size = 7200; if ($recomended_size > $max_size) { return false; } else { return true; } } //post_max_size = 100M function check_post_max_size() { $max_size = parse_size(ini_get('post_max_size')); $recomended_size = parse_size('100M'); if ($recomended_size > $max_size) { return false; } else { return true; } } //upload_max_filesize = 100M function check_upload_max_filesize() { $max_size = parse_size(ini_get('upload_max_filesize')); $recomended_size = parse_size('100M'); if ($recomended_size > $max_size) { return false; } else { return true; } } //memory_limit = 100M function check_memory_limit() { $max_size = parse_size(ini_get('memory_limit')); $recomended_size = parse_size('512M'); if ($recomended_size > $max_size) { return false; } else { return true; } } function check_mysqlnd() { return function_exists('mysqli_fetch_all'); } function base64DataToImage($imgBase64) { $img = $imgBase64; $img = str_replace('data:image/png;base64,', '', $img); $img = str_replace(' ', '+', $img); return base64_decode($img); } function getRealIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else if (!empty($_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; } else { $ip = "127.0.0.1"; } return $ip; } function cleanString($text) { $utf8 = array( '/[áàâãªä]/u' => 'a', '/[ÁÀÂÃÄ]/u' => 'A', '/[ÍÌÎÏ]/u' => 'I', '/[íìîï]/u' => 'i', '/[éèêë]/u' => 'e', '/[ÉÈÊË]/u' => 'E', '/[óòôõºö]/u' => 'o', '/[ÓÒÔÕÖ]/u' => 'O', '/[úùûü]/u' => 'u', '/[ÚÙÛÜ]/u' => 'U', '/ç/' => 'c', '/Ç/' => 'C', '/ñ/' => 'n', '/Ñ/' => 'N', '/–/' => '-', // UTF-8 hyphen to "normal" hyphen '/[’‘‹›‚]/u' => ' ', // Literally a single quote '/[“”«»„]/u' => ' ', // Double quote '/ /' => ' ', // nonbreaking space (equiv. to 0x160) ); return preg_replace(array_keys($utf8), array_values($utf8), $text); } /** * @brief return true if running in CLI, false otherwise * if is set $_GET['ignoreCommandLineInterface'] will return false * @return boolean */ function isCommandLineInterface() { return (empty($_GET['ignoreCommandLineInterface']) && php_sapi_name() === 'cli'); } /** * @brief show status message as text (CLI) or JSON-encoded array (web) * * @param array $statusarray associative array with type/message pairs * @return string */ function status($statusarray) { if (isCommandLineInterface()) { foreach ($statusarray as $status => $message) { echo $status . ":" . $message . "\n"; } } else { echo json_encode(array_map( function ($text) { return nl2br($text); } , $statusarray)); } } /** * @brief show status message and die * * @param array $statusarray associative array with type/message pairs */ function croak($statusarray) { status($statusarray); die; } function getSecondsTotalVideosLength() { $configFile = dirname(__FILE__) . '/../videos/configuration.php'; require_once $configFile; global $global; if (!User::isLogged()) { return 0; } $sql = "SELECT * FROM videos v "; $formats = ""; $values = array(); if (!User::isAdmin()) { $id = User::getId(); $sql .= " WHERE users_id = ? "; $formats = "i"; $values = array($id); } $res = sqlDAL::readSql($sql, $formats, $values); $fullData = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $seconds = 0; foreach ($fullData as $row) { $seconds += parseDurationToSeconds($row['duration']); } return $seconds; } function getMinutesTotalVideosLength() { $seconds = getSecondsTotalVideosLength(); return floor($seconds / 60); } function secondsToVideoTime($seconds) { if (!is_numeric($seconds)) { return $seconds; } $seconds = round($seconds); $hours = floor($seconds / 3600); $mins = floor($seconds / 60 % 60); $secs = floor($seconds % 60); return sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } function parseSecondsToDuration($seconds) { return secondsToVideoTime($seconds); } function parseDurationToSeconds($str) { if (is_numeric($str)) { return intval($str); } $durationParts = explode(":", $str); if (empty($durationParts[1]) || $durationParts[0] == "EE") { return 0; } if (empty($durationParts[2])) { $durationParts[2] = 0; } $minutes = intval(($durationParts[0]) * 60) + intval($durationParts[1]); return intval($durationParts[2]) + ($minutes * 60); } /** * * @global type $global * @param type $mail * call it before send mail to let YouPHPTube decide the method */ function setSiteSendMessage(&$mail) { global $global; require_once $global['systemRootPath'] . 'objects/configuration.php'; $config = new Configuration(); if ($config->getSmtp()) { error_log("Sending SMTP Email"); $mail->IsSMTP(); // enable SMTP $mail->SMTPAuth = $config->getSmtpAuth(); // authentication enabled $mail->SMTPSecure = $config->getSmtpSecure(); // secure transfer enabled REQUIRED for Gmail $mail->Host = $config->getSmtpHost(); $mail->Port = $config->getSmtpPort(); $mail->Username = $config->getSmtpUsername(); $mail->Password = $config->getSmtpPassword(); //error_log(print_r($config, true)); } else { error_log("Sending SendMail Email"); $mail->isSendmail(); } } function sendSiteEmail($to, $subject, $message) { if (empty($to)) { return false; } global $config, $global; require_once $global['systemRootPath'] . 'objects/PHPMailer/PHPMailerAutoload.php'; $contactEmail = $config->getContactEmail(); $webSiteTitle = $config->getWebSiteTitle(); try { $mail = new PHPMailer; setSiteSendMessage($mail); //$mail->SMTPDebug = 4; //Set who the message is to be sent from $mail->setFrom($contactEmail, $webSiteTitle); //Set who the message is to be sent to if (!is_array($to)) { $mail->addAddress($to); } else { $to = array_unique($to); foreach ($to as $value) { $mail->addBCC($value); } } //Set the subject line $mail->Subject = $subject . " - " . $webSiteTitle; $mail->msgHTML($message); $resp = $mail->send(); if (!$resp) { error_log("sendSiteEmail Error Info: {$mail->ErrorInfo}"); } else { error_log("sendSiteEmail Success Info: $subject " . json_encode($to)); } return $resp; } catch (phpmailerException $e) { error_log($e->errorMessage()); //Pretty error messages from PHPMailer } catch (Exception $e) { error_log($e->getMessage()); //Boring error messages from anything else! } } function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $showinfo = 0, $controls = 1, $time = 0, $objectFit = "") { //error_log("parseVideos: $videoString"); if (strpos($videoString, 'youtube.com/embed') !== false) { return $videoString . (parse_url($videoString, PHP_URL_QUERY) ? '&' : '?') . 'modestbranding=1&showinfo=' . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time&objectFit=$objectFit"; } if (strpos($videoString, 'iframe') !== false) { // retrieve the video url $anchorRegex = '/src="(.*)?"/isU'; $results = array(); if (preg_match($anchorRegex, $video, $results)) { $link = trim($results[1]); } } else { // we already have a url $link = $videoString; } if (stripos($link, 'embed') !== false) { return $link . (parse_url($link, PHP_URL_QUERY) ? '&' : '?') . 'modestbranding=1&showinfo=' . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time&objectFit=$objectFit"; } else if (strpos($link, 'youtube.com') !== false) { preg_match( '/[\\?\\&]v=([^\\?\\&]+)/', $link, $matches ); //the ID of the YouTube URL: x6qe_kVaBpg $id = $matches[1]; return '//www.youtube.com/embed/' . $id . '?modestbranding=1&showinfo=' . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&te=$time&objectFit=$objectFit"; } else if (strpos($link, 'youtu.be') !== false) { //https://youtu.be/9XXOBSsPoMU preg_match( '/youtu.be\/([a-zA-Z0-9_]+)($|\/)/', $link, $matches ); //the ID of the YouTube URL: x6qe_kVaBpg $id = $matches[1]; return '//www.youtube.com/embed/' . $id . '?modestbranding=1&showinfo=' . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&te=$time&objectFit=$objectFit"; } else if (strpos($link, 'player.vimeo.com') !== false) { // works on: // http://player.vimeo.com/video/37985580?title=0&byline=0&portrait=0 $videoIdRegex = '/player.vimeo.com\/video\/([0-9]+)\??/i'; preg_match($videoIdRegex, $link, $matches); $id = $matches[1]; return '//player.vimeo.com/video/' . $id; } else if (strpos($link, 'vimeo.com/channels') !== false) { //extract the ID preg_match( '/\/\/(www\.)?vimeo.com\/channels\/[a-z0-9-]+\/(\d+)($|\/)/i', $link, $matches ); //the ID of the Vimeo URL: 71673549 $id = $matches[2]; return '//player.vimeo.com/video/' . $id; } else if (strpos($link, 'vimeo.com') !== false) { //extract the ID preg_match( '/\/\/(www\.)?vimeo.com\/(\d+)($|\/)/', $link, $matches ); //the ID of the Vimeo URL: 71673549 $id = $matches[2]; return '//player.vimeo.com/video/' . $id; } else if (strpos($link, 'dailymotion.com') !== false) { //extract the ID preg_match( '/\/\/(www\.)?dailymotion.com\/video\/([a-zA-Z0-9_]+)($|\/)/', $link, $matches ); //the ID of the Vimeo URL: 71673549 $id = $matches[2]; return '//www.dailymotion.com/embed/video/' . $id; } else if (strpos($link, 'metacafe.com') !== false) { //extract the ID preg_match( '/\/\/(www\.)?metacafe.com\/watch\/([a-zA-Z0-9_\/-]+)$/', $link, $matches ); $id = $matches[2]; return '//www.metacafe.com/embed/' . $id; } else if (strpos($link, 'vid.me') !== false) { //extract the ID preg_match( '/\/\/(www\.)?vid.me\/([a-zA-Z0-9_-]+)$/', $link, $matches ); $id = $matches[2]; return '//vid.me/e/' . $id; } else if (strpos($link, 'rutube.ru') !== false) { //extract the ID preg_match( '/\/\/(www\.)?rutube.ru\/video\/([a-zA-Z0-9_-]+)\/.*/', $link, $matches ); $id = $matches[2]; return '//rutube.ru/play/embed/' . $id; } else if (strpos($link, 'ok.ru') !== false) { //extract the ID preg_match( '/\/\/(www\.)?ok.ru\/video\/([a-zA-Z0-9_-]+)$/', $link, $matches ); $id = $matches[2]; return '//ok.ru/videoembed/' . $id; } else if (strpos($link, 'streamable.com') !== false) { //extract the ID preg_match( '/\/\/(www\.)?streamable.com\/([a-zA-Z0-9_-]+)$/', $link, $matches ); $id = $matches[2]; return '//streamable.com/s/' . $id; } else if (strpos($link, 'twitch.tv/videos') !== false) { //extract the ID preg_match( '/\/\/(www\.)?twitch.tv\/videos\/([a-zA-Z0-9_-]+)$/', $link, $matches ); if (!empty($matches[2])) { $id = $matches[2]; return '//player.twitch.tv/?video=' . $id . '#'; } //extract the ID preg_match( '/\/\/(www\.)?twitch.tv\/[a-zA-Z0-9_-]+\/v\/([a-zA-Z0-9_-]+)$/', $link, $matches ); $id = $matches[2]; return '//player.twitch.tv/?video=' . $id . '#'; } else if (strpos($link, 'twitch.tv') !== false) { //extract the ID preg_match( '/\/\/(www\.)?twitch.tv\/([a-zA-Z0-9_-]+)$/', $link, $matches ); $id = $matches[2]; return '//player.twitch.tv/?channel=' . $id . '#'; } else if (strpos($link, '/video/') !== false) { //extract the ID preg_match( '/(http.+)\/video\/([a-zA-Z0-9_-]+)($|\/)/i', $link, $matches ); //the YouPHPTube site $site = $matches[1]; $id = $matches[2]; return $site . '/videoEmbeded/' . $id . "?autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time"; } $url = $videoString; $url_parsed = parse_url($url); if (empty($url_parsed['query'])) { return ""; } $new_qs_parsed = array(); // Grab our first query string parse_str($url_parsed['query'], $new_qs_parsed); // Here's the other query string $other_query_string = 'modestbranding=1&showinfo=' . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time"; $other_qs_parsed = array(); parse_str($other_query_string, $other_qs_parsed); // Stitch the two query strings together $final_query_string_array = array_merge($new_qs_parsed, $other_qs_parsed); $final_query_string = http_build_query($final_query_string_array); // Now, our final URL: $new_url = $url_parsed['scheme'] . '://' . $url_parsed['host'] . $url_parsed['path'] . '?' . $final_query_string; return $new_url; // return data } $canUseCDN = array(); function canUseCDN($videos_id) { if (empty($videos_id)) { return false; } global $global, $canUseCDN; if (!isset($canUseCDN[$videos_id])) { require_once $global['systemRootPath'] . 'plugin/VR360/Objects/VideosVR360.php'; $pvr360 = YouPHPTubePlugin::isEnabledByName('VR360'); // if the VR360 is enabled you can not use the CDN, it fail to load the GL $isVR360Enabled = VideosVR360::isVR360Enabled($videos_id); if ($pvr360 && $isVR360Enabled) { $ret = false; } else { $ret = true; } //error_log(json_encode(array('canUseCDN'=>$ret, '$pvr360'=>$pvr360, '$isVR360Enabled'=>$isVR360Enabled, '$videos_id'=>$videos_id))); $canUseCDN[$videos_id] = $ret; } return $canUseCDN[$videos_id]; } function clearVideosURL($fileName = "") { global $global; $path = "{$global['systemRootPath']}videos/cache/getVideosURL/"; if (empty($path)) { rrmdir($path); } else { $cacheFilename = "{$path}{$fileName}.cache"; @unlink($cacheFilename); } } $minimumExpirationTime = false; function minimumExpirationTime() { global $minimumExpirationTime; if (empty($minimumExpirationTime)) { $aws_s3 = YouPHPTubePlugin::getObjectDataIfEnabled('AWS_S3'); $bb_b2 = YouPHPTubePlugin::getObjectDataIfEnabled('Blackblaze_B2'); $secure = YouPHPTubePlugin::getObjectDataIfEnabled('SecureVideosDirectory'); $minimumExpirationTime = 60 * 60 * 24 * 365; //1 year if (!empty($aws_s3) && $aws_s3->presignedRequestSecondsTimeout < $minimumExpirationTime) { $minimumExpirationTime = $aws_s3->presignedRequestSecondsTimeout; } if (!empty($bb_b2) && $bb_b2->presignedRequestSecondsTimeout < $minimumExpirationTime) { $minimumExpirationTime = $bb_b2->presignedRequestSecondsTimeout; } if (!empty($secure) && $secure->tokenTimeOut < $minimumExpirationTime) { $minimumExpirationTime = $secure->tokenTimeOut; } } return $minimumExpirationTime; } $cacheExpirationTime = false; function cacheExpirationTime() { if (isBot()) { return 604800; // 1 week } global $cacheExpirationTime; if (empty($cacheExpirationTime)) { $obj = YouPHPTubePlugin::getObjectDataIfEnabled('Cache'); $cacheExpirationTime = @$obj->cacheTimeInSeconds; } return intval($cacheExpirationTime); } /** * tell if a file should recreate a cache, based on its time and the plugins toke expirations * @param type $filename * @return boolean */ function recreateCache($filename) { if (!file_exists($filename) || time() - filemtime($filename) > minimumExpirationTime()) { return true; } return false; } function getVideosURLPDF($fileName) { global $global; if (empty($fileName)) { return array(); } $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; $source = Video::getSourceFile($fileName, ".pdf"); $file = $source['path']; $files["pdf"] = array( 'filename' => "{$fileName}.pdf", 'path' => $file, 'url' => $source['url'], 'type' => 'pdf', ); $source = Video::getSourceFile($fileName, ".jpg"); $file = $source['path']; if (file_exists($file)) { $files["jpg"] = array( 'filename' => "{$fileName}.jpg", 'path' => $file, 'url' => $source['url'], 'type' => 'image', ); } else { $files["jpg"] = array( 'filename' => "pdf.png", 'path' => "{$global['systemRootPath']}view/img/pdf.png", 'url' => "{$global['webSiteRootURL']}view/img/pdf.png", 'type' => 'image', ); } $source = Video::getSourceFile($fileName, "_portrait.jpg"); $file = $source['path']; if (file_exists($file)) { $files["pjpg"] = array( 'filename' => "{$fileName}_portrait.jpg", 'path' => $file, 'url' => $source['url'], 'type' => 'image', ); } else { $files["pjpg"] = array( 'filename' => "pdf_portrait.png", 'path' => "{$global['systemRootPath']}view/img/pdf_portrait.png", 'url' => "{$global['webSiteRootURL']}view/img/pdf_portrait.png", 'type' => 'image', ); } $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $finish = $time; $total_time = round(($finish - $start), 4); //error_log("getVideosURLPDF generated in {$total_time} seconds. fileName: $fileName "); return $files; } function getVideosURLArticle($fileName) { global $global; if (empty($fileName)) { return array(); } $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; $files = array(); $source = Video::getSourceFile($fileName, ".jpg"); $file = $source['path']; if (file_exists($file)) { $files["jpg"] = array( 'filename' => "{$fileName}.jpg", 'path' => $file, 'url' => $source['url'], 'type' => 'image', ); } else { $files["jpg"] = array( 'filename' => "pdf.png", 'path' => "{$global['systemRootPath']}view/img/article.png", 'url' => "{$global['webSiteRootURL']}view/img/article.png", 'type' => 'image', ); } $source = Video::getSourceFile($fileName, "_portrait.jpg"); $file = $source['path']; if (file_exists($file)) { $files["pjpg"] = array( 'filename' => "{$fileName}_portrait.jpg", 'path' => $file, 'url' => $source['url'], 'type' => 'image', ); } else { $files["pjpg"] = array( 'filename' => "pdf_portrait.png", 'path' => "{$global['systemRootPath']}view/img/article_portrait.png", 'url' => "{$global['webSiteRootURL']}view/img/article_portrait.png", 'type' => 'image', ); } $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $finish = $time; $total_time = round(($finish - $start), 4); //error_log("getVideosURLPDF generated in {$total_time} seconds. fileName: $fileName "); return $files; } function getVideosURLAudio($fileName) { global $global; if (empty($fileName)) { return array(); } $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; $source = Video::getSourceFile($fileName, ".mp3"); $file = $source['path']; $files["mp3"] = array( 'filename' => "{$fileName}.mp3", 'path' => $file, 'url' => $source['url'], 'type' => 'audio', ); $source = Video::getSourceFile($fileName, ".jpg"); $file = $source['path']; if (file_exists($file)) { $files["jpg"] = array( 'filename' => "{$fileName}.jpg", 'path' => $file, 'url' => $source['url'], 'type' => 'image', ); } else { $files["jpg"] = array( 'filename' => "audio_wave.jpg", 'path' => "{$global['systemRootPath']}view/img/audio_wave.jpg", 'url' => "{$global['webSiteRootURL']}view/img/audio_wave.jpg", 'type' => 'image', ); } $source = Video::getSourceFile($fileName, "_portrait.jpg"); $file = $source['path']; if (file_exists($file)) { $files["pjpg"] = array( 'filename' => "{$fileName}_portrait.jpg", 'path' => $file, 'url' => $source['url'], 'type' => 'image', ); } else { $files["pjpg"] = array( 'filename' => "audio_wave_portrait.jpg", 'path' => "{$global['systemRootPath']}view/img/audio_wave_portrait.jpg", 'url' => "{$global['webSiteRootURL']}view/img/audio_wave_portrait.jpg", 'type' => 'image', ); } $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $finish = $time; $total_time = round(($finish - $start), 4); //error_log("getVideosURLAudio generated in {$total_time} seconds. fileName: $fileName "); return $files; } function getVideosURL($fileName, $cache = true) { global $global; if (empty($fileName)) { return array(); } $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; $path = "{$global['systemRootPath']}videos/cache/getVideosURL/"; make_path($path); $cacheFilename = "{$path}{$fileName}.cache"; //var_dump($cacheFilename, recreateCache($cacheFilename), minimumExpirationTime());$pdf = "{$global['systemRootPath']}videos/{$fileName}.pdf"; $pdf = "{$global['systemRootPath']}videos/{$fileName}.pdf"; $mp3 = "{$global['systemRootPath']}videos/{$fileName}.mp3"; if (file_exists($pdf)) { return getVideosURLPDF($fileName); } else if (file_exists($mp3)) { return getVideosURLAudio($fileName); } else if (file_exists($cacheFilename) && $cache && !recreateCache($cacheFilename)) { $json = file_get_contents($cacheFilename); $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $finish = $time; $total_time = round(($finish - $start), 4); //error_log("getVideosURL Cache in {$total_time} seconds. fileName: $fileName "); //error_log("getVideosURL age: " . (time() - filemtime($cacheFilename)) . " minimumExpirationTime: " . minimumExpirationTime()); return object_to_array(json_decode($json)); } global $global; $types = array('', '_Low', '_SD', '_HD'); $files = array(); // old require_once $global['systemRootPath'] . 'objects/video.php'; $plugin = YouPHPTubePlugin::loadPluginIfEnabled("VideoHLS"); if (!empty($plugin)) { $files = VideoHLS::getSourceFile($fileName); } foreach ($types as $key => $value) { $filename = "{$fileName}{$value}"; $source = Video::getSourceFile($filename, ".webm"); $file = $source['path']; if (file_exists($file)) { $files["webm{$value}"] = array( 'filename' => "{$fileName}{$value}.webm", 'path' => $file, 'url' => $source['url'], 'type' => 'video', ); } $source = Video::getSourceFile($filename, ".mp4"); $file = $source['path']; if (file_exists($file)) { $files["mp4{$value}"] = array( 'filename' => "{$fileName}{$value}.mp4", 'path' => $file, 'url' => $source['url'], 'type' => 'video', ); } $source = Video::getSourceFile($filename, ".mp3"); $file = $source['path']; if (file_exists($file)) { $files["mp3{$value}"] = array( 'filename' => "{$fileName}{$value}.ogg", 'path' => $file, 'url' => $source['url'], 'type' => 'audio', ); } $source = Video::getSourceFile($filename, ".ogg"); $file = $source['path']; if (file_exists($file)) { $files["ogg{$value}"] = array( 'filename' => "{$fileName}{$value}.ogg", 'path' => $file, 'url' => $source['url'], 'type' => 'audio', ); } if (empty($value)) { $source = Video::getSourceFile($filename, ".jpg"); $file = $source['path']; if (file_exists($file)) { $files["jpg"] = array( 'filename' => "{$fileName}.jpg", 'path' => $file, 'url' => $source['url'], 'type' => 'image', ); } else { $files["jpg"] = array( 'filename' => "notfound.jpg", 'path' => "{$global['systemRootPath']}view/img/notfound.jpg", 'url' => "{$global['webSiteRootURL']}view/img/notfound.jpg", 'type' => 'image', ); } $source = Video::getSourceFile($filename, ".gif"); $file = $source['path']; if (file_exists($file)) { $files["gif"] = array( 'filename' => "{$fileName}.gif", 'path' => $file, 'url' => $source['url'], 'type' => 'image', ); } else { $files["gif"] = array( 'filename' => "static2.jpg", 'path' => "{$global['systemRootPath']}view/img/static2.jpg", 'url' => "{$global['webSiteRootURL']}view/img/static2.jpg", 'type' => 'image', ); } $source = Video::getSourceFile($filename, ".webp"); $file = $source['path']; if (file_exists($file)) { $files["gif"] = array( 'filename' => "{$fileName}.webp", 'path' => $file, 'url' => $source['url'], 'type' => 'image', ); } $source = Video::getSourceFile($filename, "_portrait.jpg"); $file = $source['path']; if (file_exists($file)) { $files["pjpg"] = array( 'filename' => "{$fileName}_portrait.jpg", 'path' => $file, 'url' => $source['url'], 'type' => 'image', ); } else { $files["pjpg"] = array( 'filename' => "notfound_portrait.jpg", 'path' => "{$global['systemRootPath']}view/img/notfound_portrait.jpg", 'url' => "{$global['webSiteRootURL']}view/img/notfound_portrait.jpg", 'type' => 'image', ); } } make_path($cacheFilename); file_put_contents($cacheFilename, json_encode($files)); } $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $finish = $time; $total_time = round(($finish - $start), 4); //error_log("getVideosURL generated in {$total_time} seconds. fileName: $fileName "); return $files; } function getSources($fileName, $returnArray = false) { $name = "getSources_{$fileName}_" . intval($returnArray); /* $cached = ObjectYPT::getCache($name, 86400); //one day if (!empty($cached)) { return $cached->result; } * */ if ($returnArray) { $videoSources = $audioTracks = $subtitleTracks = array(); } else { $videoSources = $audioTracks = $subtitleTracks = ""; } $video = Video::getVideoFromFileName($fileName); if ($video['type'] !== 'audio' && function_exists('getVRSSources')) { $videoSources = getVRSSources($fileName, $returnArray); } else { $files = getVideosURL($fileName); $sources = ""; $sourcesArray = array(); foreach ($files as $key => $value) { $path_parts = pathinfo($value['path']); if ($path_parts['extension'] == "webm" || $path_parts['extension'] == "mp4" || $path_parts['extension'] == "m3u8" || $path_parts['extension'] == "mp3" || $path_parts['extension'] == "ogg") { $obj = new stdClass(); $obj->type = mime_content_type_per_filename($value['path']); if ($path_parts['extension'] == "webm" || $path_parts['extension'] == "mp4" || $path_parts['extension'] == "m3u8") { $sources .= "type}\">"; } else { $sources .= "type}\">"; } $obj->src = $value['url']; $sourcesArray[] = $obj; } } $videoSources = $returnArray ? $sourcesArray : $sources; } if (function_exists('getVTTTracks')) { $subtitleTracks = getVTTTracks($fileName, $returnArray); } if ($returnArray) { $return = array_merge($videoSources, $audioTracks, $subtitleTracks); } else { $return = $videoSources . $audioTracks . $subtitleTracks; } $obj = new stdClass(); $obj->result = $return; //ObjectYPT::setCache($name, $obj); return $return; } /** * * @param type $file_src * @return typeget image size with cache */ function getimgsize($file_src) { $name = "getimgsize_" . md5($file_src); $cached = ObjectYPT::getCache($name, 86400); //one day if (!empty($cached)) { $c = (Array) $cached; $size = array(); foreach ($c as $key => $value) { if (preg_match("/^[0-9]+$/", $key)) { $key = intval($key); } $size[$key] = $value; } return $size; } $size = @getimagesize($file_src); if (empty($size)) { $size = array(1024, 768); } ObjectYPT::setCache($name, $size); return $size; } function im_resize($file_src, $file_dest, $wd, $hd, $q = 50) { if (empty($file_dest)) { return false; } if (!file_exists($file_src)) { error_log("im_resize: Source not found: {$file_src}"); return false; } $size = getimgsize($file_src); if ($size === false) { error_log("im_resize: Could not get image size: {$file_src}"); return false; } if ($size['mime'] == 'image/pjpeg') { $size['mime'] = 'image/jpeg'; } $format = strtolower(substr($size['mime'], strpos($size['mime'], '/') + 1)); if (empty($format)) { $format = 'jpeg'; } $destformat = strtolower(substr($file_dest, -4)); if (empty($destformat)) { error_log("destformat not found {$file_dest}"); $destformat = ".jpg"; } $icfunc = "imagecreatefrom" . $format; if (!function_exists($icfunc)) { error_log("im_resize: Function does not exists: {$icfunc}"); return false; } $src = $icfunc($file_src); $ws = imagesx($src); $hs = imagesy($src); if ($ws <= $hs) { $hd = ceil(($wd * $hs) / $ws); } else { $wd = ceil(($hd * $ws) / $hs); } if ($ws <= $wd) { $wd = $ws; $hd = $hs; } $wc = ($wd * $hs) / $hd; if ($wc <= $ws) { $hc = ($wc * $hd) / $wd; } else { $hc = ($ws * $hd) / $wd; $wc = ($wd * $hc) / $hd; } $dest = imagecreatetruecolor($wd, $hd); switch ($format) { case "png": imagealphablending($dest, false); imagesavealpha($dest, true); $transparent = imagecolorallocatealpha($dest, 255, 255, 255, 127); imagefilledrectangle($dest, 0, 0, $nw, $nh, $transparent); break; case "gif": // integer representation of the color black (rgb: 0,0,0) $background = imagecolorallocate($src, 0, 0, 0); // removing the black from the placeholder imagecolortransparent($src, $background); break; } imagecopyresampled($dest, $src, 0, 0, ($ws - $wc) / 2, ($hs - $hc) / 2, $wd, $hd, $wc, $hc); $saved = false; if ($destformat == '.png') { $saved = imagepng($dest, $file_dest); } if ($destformat == '.jpg') { $saved = imagejpeg($dest, $file_dest, $q); } if (!$saved) { error_log('saving failed'); } imagedestroy($dest); imagedestroy($src); @chmod($file_dest, 0666); return true; } function im_resizeV2($file_src, $file_dest, $wd, $hd, $q = 50) { $newImage = im_resize($file_src, $file_dest, $wd, $hd); if (!$newImage) { return false; } $src = imagecreatefromjpeg($file_dest); $ws = imagesx($src); $hs = imagesy($src); if ($ws < $wd) { $dst_x = ($wd - $ws) / 2; } else { $dst_x = 0; } if ($hs < $hd) { $dst_y = ($hd - $hs) / 2; } else { $dst_y = 0; } $mapImage = imagecreatetruecolor($wd, $hd); $bgColor = imagecolorallocate($mapImage, 0, 0, 0); imagefill($mapImage, 0, 0, $bgColor); $tileImg = imagecreatefromjpeg($file_dest); imagecopy($mapImage, $tileImg, $dst_x, $dst_y, 0, 0, $ws, $hs); $saved = imagejpeg($mapImage, $file_dest, $q); return $saved; } function im_resizeV3($file_src, $file_dest, $wd, $hd) { // this trys to preserve the aspect ratio of the thumb while letterboxing it in // the same way that the encoder now does. eval('$ffmpeg ="ffmpeg -i {$file_src} -filter_complex \"scale=(iw*sar)*min({$wd}/(iw*sar)\,{$hd}/ih):ih*min({$wd}/(iw*sar)\,{$hd}/ih), pad={$wd}:{$hd}:({$wd}-iw*min({$wd}/iw\,{$hd}/ih))/2:({$hd}-ih*min({$wd}/iw\,{$hd}/ih))/2\" -sws_flags lanczos -qscale:v 2 {$file_dest}";'); exec($ffmpeg . " < /dev/null 2>&1", $output, $return_val); } function im_resize_max_size($file_src, $file_dest, $max_width, $max_height) { $fn = $file_src; $size = getimagesize($fn); $ratio = $size[0] / $size[1]; // width/height if ($size[0] <= $max_width && $size[1] <= $max_height) { $width = $size[0]; $height = $size[1]; } else if ($ratio > 1) { $width = $max_width; $height = $max_height / $ratio; } else { $width = $max_width * $ratio; $height = $max_height; } $src = imagecreatefromstring(file_get_contents($fn)); $dst = imagecreatetruecolor($width, $height); imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $height, $size[0], $size[1]); imagedestroy($src); imagejpeg($dst, $file_dest); // adjust format as needed imagedestroy($dst); } function decideMoveUploadedToVideos($tmp_name, $filename) { global $global; $obj = new stdClass(); $aws_s3 = YouPHPTubePlugin::loadPluginIfEnabled('AWS_S3'); $bb_b2 = YouPHPTubePlugin::loadPluginIfEnabled('Blackblaze_B2'); $ftp = YouPHPTubePlugin::loadPluginIfEnabled('FTP_Storage'); $path_info = pathinfo($filename); if ($path_info['extension'] === 'zip') { $dir = "{$global['systemRootPath']}videos/{$path_info['filename']}"; unzipDirectory($tmp_name, $dir); // unzip it cleanDirectory($dir); if (!empty($aws_s3)) { //$aws_s3->move_uploaded_file($tmp_name, $filename); } else if (!empty($bb_b2)) { $bb_b2->move_uploaded_directory($dir); } else if (!empty($ftp)) { //$ftp->move_uploaded_file($tmp_name, $filename); } } else { if (!empty($aws_s3)) { $aws_s3->move_uploaded_file($tmp_name, $filename); } else if (!empty($bb_b2)) { $bb_b2->move_uploaded_file($tmp_name, $filename); } else if (!empty($ftp)) { $ftp->move_uploaded_file($tmp_name, $filename); } else { if (!move_uploaded_file($tmp_name, "{$global['systemRootPath']}videos/{$filename}")) { if (!rename($tmp_name, "{$global['systemRootPath']}videos/{$filename}")) { if (!copy($tmp_name, "{$global['systemRootPath']}videos/{$filename}")) { $obj->msg = "Error on decideMoveUploadedToVideos({$tmp_name}, {$global['systemRootPath']}videos/{$filename})"; die(json_encode($obj)); } } } } } } function unzipDirectory($filename, $destination) { global $global; ini_set('memory_limit', '-1'); ini_set('max_execution_time', 7200); // 2 hours $cmd = "unzip {$filename} -d {$destination}" . " 2>&1"; error_log("unzipDirectory: {$cmd}"); exec($cmd, $output, $return_val); if ($return_val !== 0 && function_exists("zip_open")) { // try to unzip using PHP error_log("unzipDirectory: TRY to use PHP {$filename}"); $zip = zip_open($filename); if ($zip) { while ($zip_entry = zip_read($zip)) { $path = "{$destination}/" . zip_entry_name($zip_entry); error_log("unzipDirectory: fopen $path"); if (substr(zip_entry_name($zip_entry), -1) == '/') { make_path($path); } else { make_path($path); $fp = fopen($path, "w"); if (zip_entry_open($zip, $zip_entry, "r")) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); fwrite($fp, "$buf"); zip_entry_close($zip_entry); fclose($fp); } } } zip_close($zip); } else { error_log("unzipDirectory: ERROR php zip does not work"); } } else { error_log("unzipDirectory: Success {$destination}"); } @unlink($filename); } function make_path($path) { if (substr($path, -1) !== '/') { $path = pathinfo($path, PATHINFO_DIRNAME); } if (!is_dir($path)) { @mkdir($path, 0755, true); } } /** * for security clean all non secure files from directory * @param type $dir * @param type $allowedExtensions * @return type */ function cleanDirectory($dir, $allowedExtensions = array('key', 'm3u8', 'ts', 'vtt', 'jpg', 'gif', 'mp3', 'webm')) { $ffs = scandir($dir); unset($ffs[array_search('.', $ffs, true)]); unset($ffs[array_search('..', $ffs, true)]); // prevent empty ordered elements if (count($ffs) < 1) return; foreach ($ffs as $ff) { $current = $dir . '/' . $ff; if (is_dir($current)) { cleanDirectory($current, $allowedExtensions); } $path_parts = pathinfo($current); if (!empty($path_parts['extension']) && !in_array($path_parts['extension'], $allowedExtensions)) { unlink($current); } } } function decideFile_put_contentsToVideos($tmp_name, $filename) { global $global; $aws_s3 = YouPHPTubePlugin::loadPluginIfEnabled('AWS_S3'); $bb_b2 = YouPHPTubePlugin::loadPluginIfEnabled('Blackblaze_B2'); $ftp = YouPHPTubePlugin::loadPluginIfEnabled('FTP_Storage'); if (!empty($bb_b2)) { $bb_b2->move_uploaded_file($tmp_name, $filename); } else if (!empty($aws_s3)) { $aws_s3->move_uploaded_file($tmp_name, $filename); } else if (!empty($ftp)) { $ftp->move_uploaded_file($tmp_name, $filename); } else { if (!move_uploaded_file($tmp_name, "{$global['systemRootPath']}videos/{$filename}")) { $obj->msg = "Error on move_uploaded_file({$tmp_name}, {$global['systemRootPath']}videos/{$filename})"; die(json_encode($obj)); } } } if (!function_exists('mime_content_type')) { function mime_content_type($filename) { return mime_content_type_per_filename($filename); } } function mime_content_type_per_filename($filename) { $mime_types = array( 'txt' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html', 'php' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'json' => 'application/json', 'xml' => 'application/xml', 'swf' => 'application/x-shockwave-flash', 'flv' => 'video/x-flv', // images 'png' => 'image/png', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'bmp' => 'image/bmp', 'ico' => 'image/vnd.microsoft.icon', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', // archives 'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed', 'exe' => 'application/x-msdownload', 'msi' => 'application/x-msdownload', 'cab' => 'application/vnd.ms-cab-compressed', // audio/video 'mp3' => 'audio/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', 'mp4' => 'video/mp4', 'avi' => 'video/avi', 'mkv' => 'video/mkv', 'wav' => 'audio/wav', 'm4v' => 'video/mpeg', 'webm' => 'video/webm', 'wmv' => 'video/wmv', 'mpg' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'f4v' => 'video/x-flv', 'm4v' => 'video/m4v', 'm4a' => 'video/quicktime', 'm2p' => 'video/quicktime', 'rm' => 'video/quicktime', 'vob' => 'video/quicktime', 'mkv' => 'video/quicktime', '3gp' => 'video/quicktime', 'm3u8' => 'application/x-mpegURL', // adobe 'pdf' => 'application/pdf', 'psd' => 'image/vnd.adobe.photoshop', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', // ms office 'doc' => 'application/msword', 'rtf' => 'application/rtf', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', // open office 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet' ); if (filter_var($filename, FILTER_VALIDATE_URL) === FALSE) { $ext = pathinfo($filename, PATHINFO_EXTENSION); } else { $ext = pathinfo(parse_url($filename, PHP_URL_PATH), PATHINFO_EXTENSION); } if (array_key_exists($ext, $mime_types)) { return $mime_types[$ext]; } elseif (function_exists('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME); $mimetype = finfo_file($finfo, $filename); finfo_close($finfo); return $mimetype; } else { return 'application/octet-stream'; } } function combineFiles($filesArray, $extension = "js") { global $global, $advancedCustom; $cacheDir = $global['systemRootPath'] . 'videos/cache/' . $extension . "/"; if (!is_dir($cacheDir)) { mkdir($cacheDir, 0777, true); } $str = ""; $fileName = ""; foreach ($filesArray as $value) { $fileName .= $value; } if ($advancedCustom != false) { $minifyEnabled = $advancedCustom->EnableMinifyJS; } else { $minifyEnabled = false; } $md5FileName = md5($fileName) . ".{$extension}"; if (!file_exists($cacheDir . $md5FileName)) { foreach ($filesArray as $value) { if (file_exists($global['systemRootPath'] . $value)) { $str .= "\n/*{$value} created local with systemRootPath */\n" . local_get_contents($global['systemRootPath'] . $value); } else if (file_exists($value)) { $str .= "\n/*{$value} created local with full-path given */\n" . local_get_contents($value); } else { $allowed = ""; if (ini_get('allow_url_fopen')) { $allowed .= "allow_url_fopen is on and "; } if (function_exists('curl_init')) { $allowed .= "curl is on"; } else { $allowed .= "curl is off"; } $content = url_get_contents($value); if (empty($content)) { $allowed .= " - web-fallback 1 (add webSiteRootURL)"; $content = url_get_contents($global['webSiteRootURL'] . $value); } $str .= "\n/*{$value} created via web with own url ({$allowed}) */\n" . $content; } } if (($extension == "js") && ($minifyEnabled)) { require_once $global['systemRootPath'] . 'objects/jshrink.php'; $str = \JShrink\Minifier::minify($str, array('flaggedComments' => false)); } file_put_contents($cacheDir . $md5FileName, $str); } - return $global['webSiteRootURL'] . 'videos/cache/' . $extension . "/" . $md5FileName."?". filectime($cacheDir . $md5FileName); + return $global['webSiteRootURL'] . 'videos/cache/' . $extension . "/" . $md5FileName . "?" . filectime($cacheDir . $md5FileName); } function local_get_contents($path) { if (function_exists('fopen')) { $myfile = fopen($path, "r") or die("Unable to open file!"); $text = fread($myfile, filesize($path)); fclose($myfile); return $text; } } -function url_get_contents($Url, $ctx = "", $timeout=0) { +function url_get_contents($Url, $ctx = "", $timeout = 0) { global $global, $mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, $mysqlPort; $session = $_SESSION; session_write_close(); - if(!empty($timeout)){ + if (!empty($timeout)) { ini_set('default_socket_timeout', $timeout); } $global['mysqli']->close(); if (empty($ctx)) { $opts = array( "ssl" => array( "verify_peer" => false, "verify_peer_name" => false, "allow_self_signed" => true, ), ); - if(!empty($timeout)){ + if (!empty($timeout)) { ini_set('default_socket_timeout', $timeout); - $opts['http']=array('timeout' => $timeout); + $opts['http'] = array('timeout' => $timeout); } $context = stream_context_create($opts); } else { $context = $ctx; } if (ini_get('allow_url_fopen')) { try { $tmp = @file_get_contents($Url, false, $context); if ($tmp != false) { if (session_status() == PHP_SESSION_NONE) { session_start(); } $_SESSION = $session; $global['mysqli'] = new mysqli($mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, @$mysqlPort); if (!empty($global['mysqli_charset'])) { $global['mysqli']->set_charset($global['mysqli_charset']); } return $tmp; } } catch (ErrorException $e) { } } else if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $Url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - if(!empty($timeout)){ - curl_setopt($ch,CURLOPT_TIMEOUT,$timeout); - curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout+10); + if (!empty($timeout)) { + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout + 10); } $output = curl_exec($ch); curl_close($ch); if (session_status() == PHP_SESSION_NONE) { session_start(); } $_SESSION = $session; $global['mysqli'] = new mysqli($mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, @$mysqlPort); if (!empty($global['mysqli_charset'])) { $global['mysqli']->set_charset($global['mysqli_charset']); } return $output; } $result = @file_get_contents($Url, false, $context); if (session_status() == PHP_SESSION_NONE) { session_start(); } $_SESSION = $session; $global['mysqli'] = new mysqli($mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, @$mysqlPort); if (!empty($global['mysqli_charset'])) { $global['mysqli']->set_charset($global['mysqli_charset']); } return $result; } function getUpdatesFilesArray() { global $config, $global; if (!class_exists('User') || !User::isAdmin()) { return array(); } $files1 = scandir($global['systemRootPath'] . "updatedb"); $updateFiles = array(); foreach ($files1 as $value) { preg_match("/updateDb.v([0-9.]*).sql/", $value, $match); if (!empty($match)) { if ($config->currentVersionLowerThen($match[1])) { $updateFiles[] = array('filename' => $match[0], 'version' => $match[1]); } } } return $updateFiles; } function UTF8encode($data) { global $advancedCustom, $global; if (!empty($advancedCustom->utf8Encode)) { return utf8_encode($data); } if (!empty($advancedCustom->utf8Decode)) { return utf8_decode($data); } return $data; } //detect search engine bots function isBot() { if (empty($_SERVER['HTTP_USER_AGENT'])) { return true; } // User lowercase string for comparison. $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); // A list of some common words used only for bots and crawlers. $bot_identifiers = array( 'bot', 'slurp', 'crawler', 'spider', 'curl', 'facebook', 'fetch', 'loader', ); // See if one of the identifiers is in the UA string. foreach ($bot_identifiers as $identifier) { if (strpos($user_agent, $identifier) !== FALSE) { return TRUE; } } return FALSE; } /** * A function that could get me the last N lines of a log file. * @param type $filepath * @param type $lines * @param type $adaptive * @return boolean */ function tail($filepath, $lines = 1, $adaptive = true, $returnArray = false) { // Open file $f = @fopen($filepath, "rb"); if ($f === false) { return false; } // Sets buffer size, according to the number of lines to retrieve. // This gives a performance boost when reading a few lines from the file. if (!$adaptive) { $buffer = 4096; } else { $buffer = ($lines < 2 ? 64 : ($lines < 10 ? 512 : 4096)); } // Jump to last character fseek($f, -1, SEEK_END); // Read it and adjust line number if necessary // (Otherwise the result would be wrong if file doesn't end with a blank line) if (fread($f, 1) != "\n") { $lines -= 1; } // Start reading $output = ''; $chunk = ''; // While we would like more while (ftell($f) > 0 && $lines >= 0) { // Figure out how far back we should jump $seek = min(ftell($f), $buffer); // Do the jump (backwards, relative to where we are) fseek($f, -$seek, SEEK_CUR); // Read a chunk and prepend it to our output $output = ($chunk = fread($f, $seek)) . $output; // Jump back to where we started reading fseek($f, -mb_strlen($chunk, '8bit'), SEEK_CUR); // Decrease our line counter $lines -= substr_count($chunk, "\n"); } // While we have too many lines // (Because of buffer size we might have read too many) while ($lines++ < 0) { // Find first newline and remove all text before that $output = substr($output, strpos($output, "\n") + 1); } // Close file and return fclose($f); $output = trim($output); if ($returnArray) { $array = explode("\n", $output); $newArray = array(); foreach ($array as $value) { $newArray[] = array($value); } return $newArray; } else { $output; } } function encryptPassword($password, $noSalt = false) { global $advancedCustom, $global, $advancedCustomUser; if (!empty($advancedCustomUser->encryptPasswordsWithSalt) && !empty($global['salt']) && empty($noSalt)) { $password .= $global['salt']; } return md5(hash("whirlpool", sha1($password))); } function encryptPasswordVerify($password, $hash, $encodedPass = false) { global $advancedCustom, $global; if (!$encodedPass || $encodedPass === 'false') { error_log("encryptPasswordVerify: encrypt"); $passwordSalted = encryptPassword($password); // in case you enable the salt later $passwordUnSalted = encryptPassword($password, true); } else { error_log("encryptPasswordVerify: do not encrypt"); $passwordSalted = $password; // in case you enable the salt later $passwordUnSalted = $password; } //error_log("passwordSalted = $passwordSalted, hash=$hash, passwordUnSalted=$passwordUnSalted"); return $passwordSalted === $hash || $passwordUnSalted === $hash; } function isMobile() { if (empty($_SERVER["HTTP_USER_AGENT"])) { return false; } return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]); } function siteMap() { ini_set('memory_limit', '-1'); ini_set('max_execution_time', 0); global $global, $advancedCustom; $date = date('Y-m-d\TH:i:s') . "+00:00"; $xml = ' ' . $global['webSiteRootURL'] . ' ' . $date . ' always 1.00 ' . $global['webSiteRootURL'] . 'help ' . $date . ' monthly 0.50 ' . $global['webSiteRootURL'] . 'about ' . $date . ' monthly 0.50 ' . $global['webSiteRootURL'] . 'contact ' . $date . ' monthly 0.50 ' . $global['webSiteRootURL'] . 'channels ' . $date . ' daily 0.80 '; $_POST['rowCount'] = $advancedCustom->siteMapRowsLimit; $_POST['sort']['modified'] = "DESC"; $users = User::getAllUsers(true); foreach ($users as $value) { $xml .= ' ' . User::getChannelLink($value['id']) . ' ' . $date . ' daily 0.70 '; } $xml .= ' '; $_POST['rowCount'] = $advancedCustom->siteMapRowsLimit; $_POST['sort']['modified'] = "DESC"; $rows = Category::getAllCategories(); foreach ($rows as $value) { $xml .= ' ' . $global['webSiteRootURL'] . 'cat/' . $value['clean_name'] . ' ' . $date . ' weekly 0.80 '; } $xml .= ''; $_POST['rowCount'] = $advancedCustom->siteMapRowsLimit * 10; $_POST['sort']['created'] = "DESC"; $rows = Video::getAllVideos("viewable"); foreach ($rows as $value) { $xml .= ' ' . Video::getLink($value['id'], $value['clean_title']) . ' ' . $date . ' monthly 0.80 '; } $xml .= ' '; return $xml; } function object_to_array($obj) { //only process if it's an object or array being passed to the function if (is_object($obj) || is_array($obj)) { $ret = (array) $obj; foreach ($ret as &$item) { //recursively process EACH element regardless of type $item = object_to_array($item); } return $ret; } //otherwise (i.e. for scalar values) return without modification else { return $obj; } } function allowOrigin() { global $global; if (empty($_SERVER['HTTP_ORIGIN'])) { $server = parse_url($global['webSiteRootURL']); header('Access-Control-Allow-Origin: ' . $server["scheme"] . '://imasdk.googleapis.com'); } else { header("Access-Control-Allow-Origin: " . $_SERVER['HTTP_ORIGIN']); } header("Access-Control-Allow-Credentials: true"); } -if (!function_exists("rrmdir")) { - - function rrmdir($dir) { - if (is_dir($dir)) { - $objects = scandir($dir); - foreach ($objects as $object) { - if ($object != "." && $object != "..") { - if (is_dir($dir . "/" . $object)) - rrmdir($dir . "/" . $object); - else - unlink($dir . "/" . $object); - } +function rrmdir($dir) { + if (is_dir($dir)) { + $objects = scandir($dir); + foreach ($objects as $object) { + if ($object != "." && $object != "..") { + if (is_dir($dir . "/" . $object)) + rrmdir($dir . "/" . $object); + else + unlink($dir . "/" . $object); } - rmdir($dir); } + rmdir($dir); } - } /** * You can now configure it on the configuration.php * @return boolean */ function ddosProtection() { global $global; $maxCon = empty($global['ddosMaxConnections']) ? 40 : $global['ddosMaxConnections']; $secondTimeout = empty($global['ddosSecondTimeout']) ? 5 : $global['ddosSecondTimeout']; $whitelistedFiles = array( 'playlists.json.php', 'playlistsFromUserVideos.json.php' ); if (in_array(basename($_SERVER["SCRIPT_FILENAME"]), $whitelistedFiles)) { return true; } $time = time(); if (!isset($_SESSION['bruteForceBlock']) || empty($_SESSION['bruteForceBlock'])) { $_SESSION['bruteForceBlock'] = array(); $_SESSION['bruteForceBlock'][] = $time; return true; } $_SESSION['bruteForceBlock'][] = $time; //remove requests that are older than secondTimeout foreach ($_SESSION['bruteForceBlock'] as $key => $request_time) { if ($request_time < $time - $secondTimeout) { unset($_SESSION['bruteForceBlock'][$key]); } } //progressive timeout-> more requests, longer timeout $active_connections = count($_SESSION['bruteForceBlock']); $timeoutReal = ($active_connections / $maxCon) < 1 ? 0 : ($active_connections / $maxCon) * $secondTimeout; sleep($timeoutReal); //with strict mode, penalize "attacker" with sleep() above, log and then die if ($global['strictDDOSprotection'] && $timeoutReal > 0) { $str = "bruteForceBlock: maxCon: $maxCon => secondTimeout: $secondTimeout | IP: " . getRealIpAddr() . " | count:" . count($_SESSION['bruteForceBlock']); error_log($str); die($str); } return true; } function getAdsLeaderBoardBigVideo() { $ad = YouPHPTubePlugin::getObjectDataIfEnabled('ADs'); if (!empty($ad)) { if (isMobile()) { return trim($ad->leaderBoardBigVideoMobile->value); } else { return trim($ad->leaderBoardBigVideo->value); } } } function getAdsLeaderBoardTop() { $ad = YouPHPTubePlugin::getObjectDataIfEnabled('ADs'); if (!empty($ad)) { if (isMobile()) { return $ad->leaderBoardTopMobile->value; } else { return $ad->leaderBoardTop->value; } } } function getAdsLeaderBoardMiddle() { $ad = YouPHPTubePlugin::getObjectDataIfEnabled('ADs'); if (!empty($ad)) { if (isMobile()) { return $ad->leaderBoardMiddleMobile->value; } else { return $ad->leaderBoardMiddle->value; } } } function getAdsLeaderBoardFooter() { $ad = YouPHPTubePlugin::getObjectDataIfEnabled('ADs'); if (!empty($ad)) { if (isMobile()) { return $ad->leaderBoardFooterMobile->value; } else { return $ad->leaderBoardFooter->value; } } } function getAdsSideRectangle() { $ad = YouPHPTubePlugin::getObjectDataIfEnabled('ADs'); if (!empty($ad)) { if (isMobile()) { return $ad->sideRectangle->value; } else { return $ad->sideRectangle->value; } } } -function isToHidePrivateVideos(){ +function isToHidePrivateVideos() { $obj = YouPHPTubePlugin::getObjectDataIfEnabled("Gallery"); - if(!empty($obj)){ + if (!empty($obj)) { return $obj->hidePrivateVideos; } $obj = YouPHPTubePlugin::getObjectDataIfEnabled("YouPHPFlix2"); - if(!empty($obj)){ + if (!empty($obj)) { return $obj->hidePrivateVideos; } $obj = YouPHPTubePlugin::getObjectDataIfEnabled("YouTube"); - if(!empty($obj)){ + if (!empty($obj)) { return $obj->hidePrivateVideos; } return false; } + function getOpenGraph($videos_id) { global $global, $config; echo ""; if (empty($videos_id)) { echo ""; if (!empty($_GET['videoName'])) { echo ""; $video = Video::getVideoFromCleanTitle($_GET['videoName']); } } else { echo ""; $video = Video::getVideoLight($videos_id); } if (empty($video)) { echo ""; return false; } $videos_id = $video['id']; $source = Video::getSourceFile($video['filename']); if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio") && !empty($source['url'])) { $img = $source['url']; $data = getimgsize($source['path']); $imgw = $data[0]; $imgh = $data[1]; } else if ($video['type'] == "audio") { $img = "{$global['webSiteRootURL']}view/img/audio_wave.jpg"; } $type = 'video'; if ($video['type'] === 'pdf') { $type = 'pdf'; } if ($video['type'] === 'article') { $type = 'article'; } $images = Video::getImageFromFilename($video['filename'], $type); if (!empty($images->posterPortrait) && basename($images->posterPortrait) !== 'notfound_portrait.jpg' && basename($images->posterPortrait) !== 'pdf_portrait.png' && basename($images->posterPortrait) !== 'article_portrait.png') { $img = $images->posterPortrait; $data = getimgsize($images->posterPortraitPath); $imgw = $data[0]; $imgh = $data[1]; } else { $img = $images->poster; } ?> " /> " /> "; if (empty($videos_id)) { echo ""; if (!empty($_GET['videoName'])) { echo ""; $video = Video::getVideoFromCleanTitle($_GET['videoName']); } } else { echo ""; $video = Video::getVideoLight($videos_id); } if (empty($video)) { echo ""; return false; } $videos_id = $video['id']; $source = Video::getSourceFile($video['filename']); if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio") && !empty($source['url'])) { $img = $source['url']; $data = getimgsize($source['path']); $imgw = $data[0]; $imgh = $data[1]; } else if ($video['type'] == "audio") { $img = "{$global['webSiteRootURL']}view/img/audio_wave.jpg"; } $type = 'video'; if ($video['type'] === 'pdf') { $type = 'pdf'; } if ($video['type'] === 'article') { $type = 'article'; } $images = Video::getImageFromFilename($video['filename'], $type); if (!empty($images->posterPortrait) && basename($images->posterPortrait) !== 'notfound_portrait.jpg' && basename($images->posterPortrait) !== 'pdf_portrait.png' && basename($images->posterPortrait) !== 'article_portrait.png') { $img = $images->posterPortrait; $data = getimgsize($images->posterPortraitPath); $imgw = $data[0]; $imgh = $data[1]; } else { $img = $images->poster; } - - $description = str_replace(array('"', "\n", "\r"), array('', ' ' , ' '), empty(trim($video['description']))?$video['title']:$video['description']); + + $description = str_replace(array('"', "\n", "\r"), array('', ' ', ' '), empty(trim($video['description'])) ? $video['title'] : $video['description']); $duration = Video::getItemPropDuration($video['duration']); - if($duration=="PT0H0M0S"){ + if ($duration == "PT0H0M0S") { $duration = "PT0H0M1S"; } ?> "; if (empty($videos_id)) { echo ""; if (!empty($_GET['videoName'])) { echo ""; $video = Video::getVideoFromCleanTitle($_GET['videoName']); } } else { echo ""; $video = Video::getVideoLight($videos_id); } if (empty($video)) { echo ""; return false; } $videos_id = $video['id']; $source = Video::getSourceFile($video['filename']); if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio") && !empty($source['url'])) { $img = $source['url']; $data = getimgsize($source['path']); $imgw = $data[0]; $imgh = $data[1]; } else if ($video['type'] == "audio") { $img = "{$global['webSiteRootURL']}view/img/audio_wave.jpg"; } $type = 'video'; if ($video['type'] === 'pdf') { $type = 'pdf'; } if ($video['type'] === 'article') { $type = 'article'; } $images = Video::getImageFromFilename($video['filename'], $type); if (!empty($images->posterPortrait) && basename($images->posterPortrait) !== 'notfound_portrait.jpg' && basename($images->posterPortrait) !== 'pdf_portrait.png' && basename($images->posterPortrait) !== 'article_portrait.png') { $img = $images->posterPortrait; $data = getimgsize($images->posterPortraitPath); $imgw = $data[0]; $imgh = $data[1]; } else { $img = $images->poster; } - - $description = str_replace(array('"', "\n", "\r"), array('', ' ' , ' '), empty(trim($video['description']))?$video['title']:$video['description']); + + $description = str_replace(array('"', "\n", "\r"), array('', ' ', ' '), empty(trim($video['description'])) ? $video['title'] : $video['description']); $duration = Video::getItemPropDuration($video['duration']); - if($duration=="PT0H0M0S"){ + if ($duration == "PT0H0M0S") { $duration = "PT0H0M1S"; } ?> " /> " /> - http://192.168.25.16/YouPHPTube/ - 2019-02-16T02:27:59+00:00 + http://gdrive.local/YouPHPTube/ + 2019-10-23T09:05:42+00:00 always 1.00 - http://192.168.25.16/YouPHPTube/help - 2019-02-16T02:27:59+00:00 + http://gdrive.local/YouPHPTube/help + 2019-10-23T09:05:42+00:00 monthly 0.50 - http://192.168.25.16/YouPHPTube/about - 2019-02-16T02:27:59+00:00 + http://gdrive.local/YouPHPTube/about + 2019-10-23T09:05:42+00:00 monthly 0.50 - http://192.168.25.16/YouPHPTube/contact - 2019-02-16T02:27:59+00:00 + http://gdrive.local/YouPHPTube/contact + 2019-10-23T09:05:42+00:00 monthly 0.50 - http://192.168.25.16/YouPHPTube/channels - 2019-02-16T02:27:59+00:00 + http://gdrive.local/YouPHPTube/channels + 2019-10-23T09:05:42+00:00 daily 0.80 - http://192.168.25.16/YouPHPTube/channel/5c4dfa2965b0e - 2019-02-16T02:27:59+00:00 + http://gdrive.local/YouPHPTube/channel/5d964d32402cc + 2019-10-23T09:05:42+00:00 daily 0.70 - http://192.168.25.16/YouPHPTube/channel/5c4fbd79b9247 - 2019-02-16T02:27:59+00:00 + http://gdrive.local/YouPHPTube/channel/5d4d7eee21062 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5da767c49b6d4 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5c519418465d4 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5c51942726bdb + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867c0339c + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867c17905 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867c2c09f + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867c40706 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867ae8750 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867b234b2 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867b4feaa + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867b7c964 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867baa6bc + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867bce8d8 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867be3002 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867a07bc3 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867a2071f + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867a38e43 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867a5156b + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867a69e6c + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867a823dc + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867a9abb4 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867ab3353 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867acba37 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8679052c2 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867937d32 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867958cea + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86796f356 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867987a11 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8679a0281 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8679bce83 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8679e3718 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86788f40b + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8678a3a88 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8678b8013 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8678d25f8 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867802bf9 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867817007 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867836166 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8678521ca + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867866812 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86787aee6 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8677025a7 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86771aee6 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86773b3a0 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86777239f + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86778aaf7 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86779f0f0 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8677b37b9 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8677c7d7f + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8677e273b + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8675e77f1 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86760bcf0 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86762449d + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86764d1c1 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8676658e1 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86768a371 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8676a2af8 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8676c555a + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8676ddd56 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867501303 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8675199d4 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86754617a + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867565096 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867585a69 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86759e19e + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8675b685b + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8675cf170 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86740468b + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867418de7 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86743714b + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867451ebc + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86746652c + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86747aba0 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86749375c + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8674abf60 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8674c457e + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8674dcd17 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867307fbd + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86731c69f + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86733b1f3 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867355709 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867369daf + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86737e53f + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867392a04 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8673a7145 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8673bb67e + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8673cfd9d + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8673e43a6 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8672057a3 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86721de74 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86723f375 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d86725f2ac + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d867277bb2 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8672900ef + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8672a88c0 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8672bef1e + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8672d3651 + 2019-10-23T09:05:42+00:00 + daily + 0.70 + + + + http://gdrive.local/YouPHPTube/channel/5d4d8672e7c00 + 2019-10-23T09:05:42+00:00 daily 0.70 - http://192.168.25.16/YouPHPTube/cat/default - 2019-02-16T02:27:59+00:00 + http://gdrive.local/YouPHPTube/cat/teste-sdaf-sfad + 2019-10-23T09:05:42+00:00 weekly 0.80 - + - http://192.168.25.16/YouPHPTube/video/video-automatically-booked - 2019-02-16T02:27:59+00:00 - monthly + http://gdrive.local/YouPHPTube/cat/default + 2019-10-23T09:05:42+00:00 + weekly 0.80 - + + + http://gdrive.local/YouPHPTube/cat/-5c6aabccb1467 + 2019-10-23T09:05:42+00:00 + weekly + 0.80 + + + + http://gdrive.local/YouPHPTube/cat/-sd + 2019-10-23T09:05:42+00:00 + weekly + 0.80 + + + + http://gdrive.local/YouPHPTube/cat/- + 2019-10-23T09:05:42+00:00 + weekly + 0.80 + + - http://192.168.25.16/YouPHPTube/video/creating-images - 2019-02-16T02:27:59+00:00 + http://gdrive.local/YouPHPTube/video/tk-kravitz-featuring-jacquees-ocean + 2019-10-23T09:05:42+00:00 monthly 0.80 - http://192.168.25.16/YouPHPTube/video/youphptubeintro - 2019-02-16T02:27:59+00:00 + http://gdrive.local/YouPHPTube/video/video-de-teste + 2019-10-23T09:05:42+00:00 monthly 0.80 - http://192.168.25.16/YouPHPTube/video/-marvel-avengers-the-key - 2019-02-16T02:27:59+00:00 + http://gdrive.local/YouPHPTube/video/video + 2019-10-23T09:05:42+00:00 monthly 0.80 \ No newline at end of file diff --git a/view/configurations_body.php b/view/configurations_body.php index b55169586..99947f103 100644 --- a/view/configurations_body.php +++ b/view/configurations_body.php @@ -1,808 +1,812 @@
-
- -

- - -

-
- - -
- getTheme(); - if ($fileEx == $savedTheme) { +
+

+
+ +

+ + +

+
+ + +
+ getTheme(); + if ($fileEx == $savedTheme) { + ?> + + - +
+ " class="img-responsive img-radio"> + + +
-
- " class="img-responsive img-radio"> - - -
- -
+ +
+
+
$secondsTotal) { $percent = intval($secondsTotal / $secondsLimit * 100); } else { $percent = 100; } ?> and you have minutes of storage
% of your storage limit used
is Present
Your server is , you must install Apache
PHP is Present
Your PHP version is , you must install PHP 5.6.x or greater
Your videos directory is writable
Your videos directory must be writable
The video directory does not exists, YouPHPTube had no permition to create it, you must create it manualy!
sudo mkdir 

Then you can set the permissions.
sudo chmod -R 777 
Your post_max_size is
Your post_max_size is , it must be at least 100M
Edit the php.ini file
sudo nano 
Your upload_max_filesize is
Your upload_max_filesize is , it must be at least 100M
Edit the php.ini file
sudo nano 
-
- - -
- -
- - -
- -
-
- -
-
- -
- -
-
- -
-
- - " class="form-control" type="text" value="getWebSiteTitle(); ?>" > -
-
-
-
- -
-
- - " class="form-control" type="text" value="getLanguage(); ?>" > -
- locale -
-
-
- -
-
- - " class="form-control" type="email" value="getContactEmail(); ?>" > -
- -
-
-
- -
-
- - -
-
-
+
+
+ +
+

+
+
+ +
+
+ + " class="form-control" type="text" value="getLanguage(); ?>" > +
+ locale +
+
+
+ +
+
+ + " class="form-control" type="email" value="getContactEmail(); ?>" > +
+ +
+
-
- -
-
- - -
-
-
+
+ +
+
+ + +
+
+
-
- -
-
- +
+ +
+
+ + +
+
+
+ +
+ +
+
+ + + +
+
+
+ +
+ +
+
+ getAutoplay())) { + echo "checked"; + } + ?> > + +
+
+
-
+
+
+
+

+
+ +
+ +
+
+ + " class="form-control" type="text" value="getWebSiteTitle(); ?>" > +
+
+
+
+ +
+ + +
+ +
+
+ +
+
+ +
+ +
-
- -
-
- getAutoplay())) { - echo "checked"; - } - ?> > -
- -
+
-
- - -
-
- - - -
- the sitemap file must be writable - sudo chmod 777 -
- -
-
-
- -
- - -
- : https://encoder.youphptube.com/ or - -
-
-
- -
- -
- -
-
- - -
- -
-
- getDisable_analytics())) { - echo "checked"; - } - ?> aria-describedby="disable_analyticsHelp"> - +
+
+
+

+
+ +
+
+ + + +
+ the sitemap file must be writable + sudo chmod 777 +
+ +
+
+
+ +
+ + +
+ : https://encoder.youphptube.com/ or + +
+
+
+ +
+ +
+ +
+
+ + +
+ +
+
+ getDisable_analytics())) { + echo "checked"; + } + ?> aria-describedby="disable_analyticsHelp"> + +
+ +
+
+ +
+ +
+ +
+ getDisable_youtubeupload())) { + echo "checked"; + } + ?> > + +
+
+
+ +
+ +
+
+ getAllow_download())) { + echo "checked"; + } + ?> aria-describedby="allow_downloadHelp"> + +
+ +
+
-
-
-
- -
- -
- getDisable_youtubeupload())) { - echo "checked"; - } - ?> > - -
-
+
+ +
+

Email Configuration

+
+ +
+

+ + If you are not sure how to configure your email, + please try this help +

+
+ + +
+ +
+
+ getSmtp())) { + echo "checked"; + } + ?> > + +
+
+
+
+ +
+
+ getSmtpAuth())) { + echo "checked"; + } + ?> > + +
+
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
-
- -
-
- getAllow_download())) { - echo "checked"; - } - ?> aria-describedby="allow_downloadHelp"> - -
- -
-
-
-
- -
-
-

Email Configuration

- If you are not sure how to configure your email, - please try this help - -
-
-
-
- -
-
- getSmtp())) { - echo "checked"; - } - ?> > - -
-
-
-
- -
-
- getSmtpAuth())) { - echo "checked"; - } - ?> > -
+
-
- -
- - -
-
- -
- -
- - -
-
- -
- -
- -
-
- -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- -

-
- - -
- -
- - For Google Analytics code: https://analytics.google.com
- Leave blank for native code -
+
+ +
+ + For Google Analytics code: https://analytics.google.com
+ Leave blank for native code
-
- -
- -
- Google AD Sense and any other Ads provider are moved to the plugins'>ADs plugin -
+
+
+ +
+ +
+ Google AD Sense and any other Ads provider are moved to the plugins'>ADs plugin
- -
+
\ No newline at end of file diff --git a/view/include/navbar.php b/view/include/navbar.php index ae2932bc8..ba5e9c068 100644 --- a/view/include/navbar.php +++ b/view/include/navbar.php @@ -1,975 +1,985 @@ userMustBeLoggedIn) && empty($advancedCustom->disableNavbar)) || $thisScriptFile["basename"] === "signUp.php" || $thisScriptFile["basename"] === "userRecoverPass.php") || User::isLogged()) { $updateFiles = getUpdatesFilesArray(); ?> underMenuBarHTMLCode->value)) { echo $advancedCustom->underMenuBarHTMLCode->value; } } else if ($thisScriptFile["basename"] !== 'user.php' && empty($advancedCustom->disableNavbar)) { header("Location: {$global['webSiteRootURL']}user"); } ?> diff --git a/view/js/script.js b/view/js/script.js index 2b5077a7b..1d2150ce2 100644 --- a/view/js/script.js +++ b/view/js/script.js @@ -1,417 +1,452 @@ var modal; var player; var floatLeft = ""; var floatTop = ""; var floatWidth = ""; var floatHeight = ""; var changingVideoFloat = 0; var floatClosed = 0; var fullDuration = 0; var isPlayingAd = false; var mainVideoHeight = 0; var doNotFloatVideo = false; var mouseX; var mouseY; $(document).mousemove(function (e) { mouseX = e.pageX; mouseY = e.pageY; }); String.prototype.stripAccents = function () { var translate_re = /[àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ]/g; var translate = 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY'; return (this.replace(translate_re, function (match) { return translate.substr(translate_re.source.indexOf(match) - 1, 1); }) ); }; function clean_name(str) { str = str.stripAccents().toLowerCase(); return str.replace(/\W+/g, "-"); } try { if ($(".thumbsJPG").length) { $('.thumbsJPG').lazy({ effect: 'fadeIn', visibleOnly: true, // called after an element was successfully handled afterLoad: function (element) { element.removeClass('blur'); } }); } -} catch (e) {} +} catch (e) { +} var pleaseWaitIsINUse = false; $(document).ready(function () { modal = modal || (function () { var pleaseWaitDiv = $("#pleaseWaitDialog"); if (pleaseWaitDiv.length === 0) { pleaseWaitDiv = $('').appendTo('body'); } return { showPleaseWait: function () { if (pleaseWaitIsINUse) { return false; } pleaseWaitIsINUse = true; pleaseWaitDiv.modal(); }, hidePleaseWait: function () { pleaseWaitDiv.modal('hide'); pleaseWaitIsINUse = false; }, setProgress: function (valeur) { pleaseWaitDiv.find('.progress-bar').css('width', valeur + '%').attr('aria-valuenow', valeur); }, setText: function (text) { pleaseWaitDiv.find('h2').html(text); }, }; })(); $('[data-toggle="popover"]').popover(); $('[data-toggle="tooltip"]').tooltip(); $(".thumbsImage").on("mouseenter", function () { gifId = $(this).find(".thumbsGIF").attr('id'); $(".thumbsGIF").fadeOut(); if (gifId != undefined) { id = gifId.replace('thumbsGIF', ''); $(this).find(".thumbsGIF").height($(this).find(".thumbsJPG").height()); $(this).find(".thumbsGIF").width($(this).find(".thumbsJPG").width()); try { $(this).find(".thumbsGIF").lazy({effect: 'fadeIn'}); } catch (e) { } $(this).find(".thumbsGIF").stop(true, true).fadeIn(); } }); $(".thumbsImage").on("mouseleave", function () { $(this).find(".thumbsGIF").stop(true, true).fadeOut(); }); if ($(".thumbsJPG").length) { $('.thumbsJPG').lazy({ effect: 'fadeIn', visibleOnly: true, // called after an element was successfully handled afterLoad: function (element) { element.removeClass('blur'); } }); } mainVideoHeight = $('#videoContainer').innerHeight(); $(window).resize(function () { mainVideoHeight = $('#videoContainer').innerHeight(); }); $(window).scroll(function () { if (changingVideoFloat || doNotFloatVideo) { return false; } changingVideoFloat = 1; var s = $(window).scrollTop(); if (s > mainVideoHeight) { if (!$('#videoContainer').hasClass("floatVideo") && !floatClosed) { $('#videoContainer').hide(); $('#videoContainer').addClass('floatVideo'); $('#videoContainer').parent().css('height', mainVideoHeight); if (parseInt(floatTop) < 70) { floatTop = "70px"; } if (parseInt(floatLeft) < 10) { floatLeft = "10px"; } $("#videoContainer").css({"top": floatTop}); $("#videoContainer").css({"left": floatLeft}); $("#videoContainer").css({"height": floatHeight}); $("#videoContainer").css({"width": floatWidth}); $("#videoContainer").resizable({ aspectRatio: 16 / 9, minHeight: 150, minWidth: 266 }); $("#videoContainer").draggable({ handle: ".move", containment: ".principalContainer" }); changingVideoFloat = 0; $('#videoContainer').fadeIn(); $('#floatButtons').fadeIn(); } else { changingVideoFloat = 0; } } else { floatClosed = 0; if ($('#videoContainer').hasClass("floatVideo")) { closeFloatVideo(); } else { changingVideoFloat = 0; } } }); $("a").each(function () { var location = window.location.toString() var res = location.split("?"); pathWitoutGet = res[0]; if ($(this).attr("href") == window.location.pathname || $(this).attr("href") == window.location || $(this).attr("href") == pathWitoutGet) { $(this).addClass("selected"); } }); + + + $('#clearCache, .clearCacheButton').on('click', function (ev) { + ev.preventDefault(); + modal.showPleaseWait(); + $.ajax({ + url: webSiteRootURL + 'objects/configurationClearCache.json.php', + success: function (response) { + if (!response.error) { + swal("Congratulations!", "Your cache has been cleared!", "success"); + } else { + swal("Sorry!", "Your cache has NOT been cleared!", "error"); + } + modal.hidePleaseWait(); + } + }); + }); + + $('#generateSiteMap, .generateSiteMapButton').on('click', function (ev) { + ev.preventDefault(); + modal.showPleaseWait(); + $.ajax({ + url: webSiteRootURL + 'objects/configurationGenerateSiteMap.json.php', + success: function (response) { + if (!response.error) { + swal("Congratulations!", "File created!", "success"); + } else { + swal("Sorry!", "File NOT created!", "error"); + } + modal.hidePleaseWait(); + } + }); + }); + }); function removeTracks() { var oldTracks = player.remoteTextTracks(); var i = oldTracks.length; while (i--) { player.removeRemoteTextTrack(oldTracks[i]); } } function changeVideoSrc(vid_obj, source) { var srcs = []; removeTracks(); for (i = 0; i < source.length; i++) { if (source[i].type) { srcs.push(source[i]); } else if (source[i].srclang) { player.addRemoteTextTrack(source[i]); } } vid_obj.src(srcs); setTimeout(function () { changeVideoSrcLoad(); }, 1000); } function changeVideoSrcLoad() { console.log("changeVideoSrcLoad: Try to load player"); player.load(); player.ready(function () { console.log("changeVideoSrcLoad: Player ready"); var err = this.error(); if (err && err.code) { console.log("changeVideoSrcLoad: Load player Error"); setTimeout(function () { changeVideoSrcLoad(); }, 1000); } else { console.log("changeVideoSrcLoad: Load player Success, Play"); setTimeout(function () { player.load(); player.play(); }, 1000); } }); ; } /** * * @param {String} str 00:00:00 * @returns {int} int of seconds */ function strToSeconds(str) { var partsOfStr = str.split(':'); var seconds = parseInt(partsOfStr[2]); seconds += parseInt(partsOfStr[1]) * 60; seconds += parseInt(partsOfStr[0]) * 60 * 60; return seconds; } /** * * @param {int} seconds * @param {int} level 3 = 00:00:00 2 = 00:00 1 = 00 * @returns {String} 00:00:00 */ function secondsToStr(seconds, level) { var hours = parseInt(seconds / (60 * 60)); var minutes = parseInt(seconds / (60)); seconds = parseInt(seconds % (60)); hours = hours > 9 ? hours : "0" + hours; minutes = minutes > 9 ? minutes : "0" + minutes; seconds = seconds > 9 ? seconds : "0" + seconds; switch (level) { case 3: return hours + ":" + minutes + ":" + seconds; break; case 2: return minutes + ":" + seconds; break; case 1: return seconds; break; default: return hours + ":" + minutes + ":" + seconds; } } function validateEmail(email) { var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } function subscribe(email, user_id) { $.ajax({ url: webSiteRootURL + 'objects/subscribe.json.php', method: 'POST', data: { 'email': email, 'user_id': user_id }, success: function (response) { if (response.subscribe == "i") { $('.subs' + user_id).removeClass("subscribed"); $('.subs' + user_id + ' b.text').text("Subscribe"); $('b.textTotal' + user_id).text(parseInt($('b.textTotal' + user_id).first().text()) - 1); } else { $('.subs' + user_id).addClass("subscribed"); $('.subs' + user_id + ' b.text').text("Subscribed"); $('b.textTotal' + user_id).text(parseInt($('b.textTotal' + user_id).first().text()) + 1); } $('#popover-content #subscribeEmail').val(email); $('.subscribeButton' + user_id).popover('hide'); } }); } function subscribeNotify(email, user_id) { $.ajax({ url: webSiteRootURL + 'objects/subscribeNotify.json.php', method: 'POST', data: { 'email': email, 'user_id': user_id }, success: function (response) { if (response.notify) { $('.notNotify' + user_id).addClass("hidden"); $('.notify' + user_id).removeClass("hidden"); } else { $('.notNotify' + user_id).removeClass("hidden"); $('.notify' + user_id).addClass("hidden"); } } }); } function closeFloatVideo() { $('#videoContainer').fadeOut('fast', function () { // this is to remove the dragable and resize floatLeft = $("#videoContainer").css("left"); floatTop = $("#videoContainer").css("top"); floatWidth = $("#videoContainer").css("width"); floatHeight = $("#videoContainer").css("height"); $("#videoContainer").css({"top": ""}); $("#videoContainer").css({"left": ""}); $("#videoContainer").css({"height": ""}); $("#videoContainer").css({"width": ""}); $('#videoContainer').parent().css('height', ''); $('#videoContainer').removeClass('floatVideo'); $("#videoContainer").resizable('destroy'); $("#videoContainer").draggable('destroy'); $('#floatButtons').hide(); changingVideoFloat = 0; }); $('#videoContainer').fadeIn(); } function mouseEffect() { $(".thumbsImage").on("mouseenter", function () { try { $(this).find(".thumbsGIF").lazy({effect: 'fadeIn'}); } catch (e) { } $(this).find(".thumbsGIF").height($(this).find(".thumbsJPG").height()); $(this).find(".thumbsGIF").width($(this).find(".thumbsJPG").width()); $(this).find(".thumbsGIF").stop(true, true).fadeIn(); }); $(".thumbsImage").on("mouseleave", function () { $(this).find(".thumbsGIF").stop(true, true).fadeOut(); }); } function isMobile() { var check = false; (function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true })(navigator.userAgent || navigator.vendor || window.opera); return check; } function copyToClipboard(text) { var $temp = $(""); $("body").append($temp); $temp.val(text).select(); document.execCommand("copy"); $temp.remove(); } var last_videos_id = 0; var last_currentTime = -1; function addView(videos_id, currentTime) { if (last_videos_id == videos_id && last_currentTime == currentTime) { return false; } last_videos_id = videos_id; last_currentTime = currentTime; $.ajax({ url: webSiteRootURL + 'objects/videoAddViewCount.json.php', method: 'POST', data: { 'id': videos_id, 'currentTime': currentTime }, success: function (response) { $('.view-count' + videos_id).text(response.count); } }); } function getPlayerButtonIndex(name) { var children = player.getChild('controlBar').children(); for (i = 0; i < children.length; i++) { if (children[i].name_ === name) { return i; } } return children.length; } function copyToClipboard(text) { $('#elementToCopy').css({'top': mouseY, 'left': mouseX}).fadeIn('slow'); $('#elementToCopy').val(text); $('#elementToCopy').focus(); $('#elementToCopy').select(); document.execCommand('copy'); } function nl2br(str, is_xhtml) { if (typeof str === 'undefined' || str === null) { return ''; } var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '
' : '
'; return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2'); }